<%-- 
    Document   : result
    Created on : 2016-12-7, 13:39:38
    Author     : 52461
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="${base}/css/bootstrap.css" rel="stylesheet">
        <link href="${base}/css/font-awesome.css" rel="stylesheet">
        <link href="${base}/css/material-kit.css" rel="stylesheet">
        <link rel="stylesheet" href="${base}/css/nprogress.css"/>

        <script type="text/javascript" src="${base}/js/jquery-1.9.1.js"></script>
        <script type="text/javascript" src="${base}/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="${base}/js/material.min.js"></script>
        <script type="text/javascript" src="${base}/js/material-kit.js"></script>
        <script type="text/javascript" src="${base}/js/angular/angular.min.js"></script>
        <script type="text/javascript" src="${base}/js/angular-base.js"></script>
        <script type="text/javascript" src="${base}/js/angular/ui-bootstrap-tpls-0.12.0.min.js"></script>
        <script type="text/javascript" src="${base}/js/jquery.cxhd.js"></script>
        <script type="text/javascript" src="${base}/js/nprogress.js"></script>
    </head>
    <body ng-app="result" ng-controller="mainCtrl" style="font-family:微软雅黑;background: #ffffff;overflow: auto ">
        <div id="myRpt" style="overflow: auto; margin-top: 10px;">
            <div ng-if="item.result_type == 'image'" id="mod2"  class="mod-2" style="width: 100%">

                <img  ng-repeat="rimage in resultImages" ng-click="selectOneImage('image' + $index)" style="display: block;max-width: 100%;margin-left: auto;margin-right: auto;max-height: 100%" id="image{{$index}}" ng-src="{{rimage}}" alt="">

            </div>
            <div ng-if="item.result_type == 'text'" id="mod1" class="mod-1" style="font-size: 18px;overflow: auto">
                <table class="table">
                    <tr ng-repeat="re in results">
                        <td ng-bind="re"></td>
                    </tr>
                </table>

            </div>
            <div  ng-if="item.result_type == 'table' && item.data_type == 'lis_detail'" id="mod3"  class="mod-3" style="max-width: 600px;font-size: 12px;overflow: auto;font-size: 14px; display: none">
                <table width="100%" style="border-spacing:0px">
                    <tr>
                        <td colspan="5" align="right" >时间：{{lisResults[0].date_test}}</td>
                    </tr>
                    <tr class="xl_head">
                        <th align="center">简称</th>
                        <th align="center">检验项目</th>
                        <th align="center">结果</th>
                        <th align="center">备注</th>
                        <th align="center">参考范围</th>
                        <th align="center">单位</th>
                    </tr>
                    <tr ng-repeat="re in lisResults">
                        <td align="left" ng-bind="re.item_code"></td>
                        <td align="left" ng-bind="re.item_name"></td>
                        <td align="left"  ng-bind="re.test_value"></td>
                        <td align="left"  ng-bind="re.text_note"></td>

                        <td align="left"  ng-bind="re.text_range"></td>
                        <td align="left"  ng-bind="re.text_danwei"></td>
                    </tr>
                </table>

            </div>

            <div ng-if="item.result_type == 'html'" id="mod4"  class="mod-4" style="overflow-x: hidden;overflow-y: auto; ">


            </div>
            <!--<iframe id="pdf_src" ng-if="item.result_type == 'pdf'" id="mod5" ng-src="{{pdfSrc}}" frameBorder=0 scrolling=auto width="100%" height="100%"  class="mod-5"   style="overflow-x: hidden;overflow-y: auto;position: relative">-->
                 <div ng-if="item.result_type == 'pdf'" id="mod5"  class="mod-5" style="width: 100%">

                <img  ng-repeat="rimage in pdfImages"  style="display: block;max-width: 100%;margin-left: auto;margin-right: auto;max-height: 100%" id="image{{$index}}" src="getPdfImage?path={{rimage}}" alt="">

            </div>

            <!--</iframe>-->
            <video ng-if="item.result_type == 'video'" id="mod6" width="100%" controls=""  ng-src="{{videoSrc}}"></video>
        </div>
    </body>
</html>
<script>

    angular.module("result", ["baseModule"])
            .controller("mainCtrl", function ($scope, base) {

                var item = JSON.parse('<%=request.getAttribute("item")%>');

                $scope.item = item;
                //console.log(item);
                if (item.result_type == "image") {
                    $scope.imageDetailStatus = true;
                    $scope.showId = "mod2";
                    $scope.resultImages = item.event_result.split(",");
                    for (var i in $scope.resultImages) {
                        $scope.resultImages[i] = "getImage?fileId=" + $scope.resultImages[i];
                    }

                } else if (item.result_type == "pdf") {
                    
                    $.post("getPdfToImage",{fileId:item.event_result},function(data){
                            $scope.pdfImages = data;
                             $scope.$apply();
                        })
                   // $scope.pdfSrc = 'getPdf?fileId=' + item.event_result;

                } else if (item.result_type == "video") {

                    $scope.videoSrc = 'getVideo?fileId=' + item.event_result;

                } else if (item.result_type == 'table') {
                    $scope.imageDetailStatus = false;
                    if (item.data_type == 'lis_detail') {

                        $scope.showId = "mod3";

                        $.post("getLisResult", {pk: item.detail_id}, function (data) {

                            if (data) {
                                $("#mod3").show();
                                $scope.lisResults = data;
                                $scope.$apply();
                            }
                        })
                    }

                } else {
                    $scope.imageDetailStatus = false;
                    base.post("getResult", {pk: item.pk, type: item.result_type}).get(function (data) {

                        if (data) {
                            if (item.result_type == 'html') {


                                $scope.showId = "mod4";

                                $(".mod-4").html(unescape(data));
                                setTimeout(function () {
                                    $(".series_institution").parent().prependTo($("#paper"));
                                }, 500);
                            } else {
                                $scope.showId = "mod1";

                                $scope.results = data.split("@");

                            }

                        }
                    })
                }
            })

    function autoHeight() {
        var bHeight = $(window).height();


      
        $("#pdf_src").height(bHeight - 10);
              $(".mod-4").height(bHeight - 10);

    }
    autoHeight();


    $(window).resize(function () {
        autoHeight();
    });
</script>
